﻿@using GameSchool.Models.OnTheFlyModels
@using GameSchool.Extra
@using GameSchool.Models
@model GameSchool.Models.Course
           

@{
    ViewBag.Title = "Nánar um námskeið";
    Layout = "~/Views/Shared/_Layout.cshtml";
    
    ICollection<GameSchool.Models.VideoLecture> videoLectures ;
    if (ViewData.ContainsKey("VideoLectures"))
    {
        videoLectures = (ICollection<GameSchool.Models.VideoLecture>) ViewData["VideoLectures"];
    }
    else
    {
        videoLectures = new List<GameSchool.Models.VideoLecture>();
    }
}

	<script type="text/javascript">
	    
        
        $(function () {
	        $("#CourseDetails").tabs({
	            collapsible: true
	        });
	    });

	    // Accordion fyrir borðin
	    $(function () {
	        $("#level_accordion").accordion();
	    });


	</script>

    <style type="text/css">
        #level_accordion
        {
        	margin-top:50px;
        }
        #level_accordion .ui-icon { display: none; }
        #level_accordion .ui-icon-custom { display: inline; }

    </style>

<h2>Námskeiðið @Html.DisplayFor(model => model.CourseName)</h2>

<div id="CourseDetails">
	<ul>
		<li><a href="#tabs-1">Tilkynningar</a></li>
		<li><a href="#tabs-2">Kennarar</a></li>
		<li><a href="#tabs-3">Bækur</a></li>
		<li><a href="#tabs-4">Lýsing</a></li>
        @if (videoLectures != null)
        {
		    <li><a href="#tabs-5">Fyrirlestrar</a></li>
        }
	</ul>
	<div id="tabs-1">
            @foreach (var item in Model.Notifications.OrderByDescending(x => x.EntryDate).ToList())
            {
                <text>
					<strong>@item.Title</strong> 
					<small>skrifað af @item.Person.Fullname þann @item.EntryDate </small>
                    <br />
                    @item.NotificationMessage
                    <br />
                    <br />
                </text>
            }    
	</div>
	<div id="tabs-2">
            @foreach (var item in Model.Teachers)
            {
				@Html.DisplayFor(itemModel => item.Teacher.Fullname)<br /> 
            }
	</div>
	<div id="tabs-3">
            @{Html.RenderPartial("BooksInCourse", Model.CourseBooks);}
	</div>
	<div id="tabs-4">
            @Html.DisplayFor(model => model.Description)
	</div>

    @if (videoLectures != null)
    {
	<div id="tabs-5">
            @{Html.RenderPartial("VideoLectures", videoLectures);}
	</div>
    }       

</div>


@if (ViewData.ContainsKey("CourseCompleted") && (bool) ViewData["CourseCompleted"])
{ 
    <text>
    <div class="course_complete">
        Þú hefur lokið við þetta námskeið! :)
    </div>
    </text>
}
@if (ViewData.ContainsKey("CourseLevelInfos"))
{
    LevelParticipateInfoList lvlPartInfoList = (LevelParticipateInfoList)ViewData["CourseLevelInfos"];

    CustomTypes.LevelParticipateStateType lvlStateType;
    
    <text>

    <div id="level_accordion">

        

    @foreach (LevelParticipateInfo lvlprt in lvlPartInfoList)
    {
        
        if (lvlprt.LevelParticipate == null)
        {
            lvlStateType = GameSchool.Extra.CustomTypes.LevelParticipateStateType.Locked;
        }
        else
        {
            lvlStateType = lvlprt.LevelParticipate.StateType;
        }
        
        
            <h3><a href="#">@(lvlprt.Level.LevelNumber). @lvlprt.Level.LevelName <span class="ui-icon ui-icon-custom ui-icon-@(CustomTypes.LevelParticipateIcon(lvlStateType))"></span></a> </h3>
            <div>

            @if (lvlprt.LevelParticipate == null)
            {
                <span>Þetta borð er ennþá læst.</span> 
            }
            else
            { 
                if (lvlprt.LevelParticipate.StateType == CustomTypes.LevelParticipateStateType.Finished)
                { 
                // TODO: Level participate info..
                    
                    <span>Þú hefur lokið þessu borði - sjá einkunnir að neðan..</span>
                }
                else
                { 
                    <span>Þetta borð er í vinnslu... HJÁ ÞÉR!!! </span>
                IEnumerable<Assignment> assignments = lvlprt.Level.Assignments.Where(x => x.Active).ToList();

                if (assignments.Count() > 0)
                { 
                    <text>
                    <ul>
                    @foreach (var item in assignments)
                        { 
                            <li>@Html.ActionLink(item.Title + "(" + item.Description + ")", "OpenAssignment", "Assignment", new { id = item.AssignmentId }, null) </li>
                        }
                    </ul>
                    </text>
                }

                }
                <br />
                
                
            }
            
            </div>
    }

    </div>

    </text>
}

<div style="display:none;">


    <div class="display-label">Þú ert í borði </div>
    <div class="display-field">
            @foreach (var item in Model.Levels)
            {
                @Html.DisplayFor(itemModel => item.LevelNumber)
            }
          
              <br />(vitlaust, núna bara listi yfir öll borð í námskeiði <br />
               vantar að vita hver er innskráður og í hvaða level hann er í þessum áfanga)<br />
            @Html.DisplayFor(model => model.Levels.Count)
            ## Ætti að vera Total fjöldi borða í þessum áfanga, skoða þegar það eru komin fleiri!! <!--Current Borð / Total Borð-->
    </div>

    <div class="display-label">Stig í næsta leikmann á undan: </div>
    <div class="display-field">
            ##<!--stig á undan-->
    </div>

    <div class="display-label">Stig á undan næsta leikmanni á eftir: </div>
    <div class="display-field">
            ##<!--stig í næsta-->
    </div>

    		<div class="tabbla">
			<table>
				<tr>
					<th>Ókláruð verkefni/próf</th>
					<th>Heilasellur í boði</th>
					<th>Auka heilasellur í boði</th>
				</tr>
				<tr>
					<td>##Nafn ókláraðra verkefna/prófa</td>
					<td>##Stig fyrir heimadæmi</td>
					<td>##Aukastig fyrir heimadæmin</td>
				</tr>
				<tr>
					<td>Endurtekið</td>
					<td>fyrir öll</td>
					<td>ókláruð verkefni</td>
				</tr>
			</table>
		</div>
  
  
    <div class="tabbla">
			<table>
				<tr>
					<th>Verkefnum/prófum lokið</th>
					<th>Einkunn</th>
					<th>Heilasellur</th>
				</tr>                
                 
                <tr>
					<td>##Nafn kláraðra verkefna/prófa</td>
					<td>##Einkunn fyrir heimadæmi</td>
					<td>##Stig fyrir heimadæmin</td>
				</tr>
				<tr>
					<td>Endurtekið</td>
					<td>fyrir öll</td>
					<td>kláruð verkefni</td>
				</tr>
			</table>
		</div>
        




<p>
    @Html.ActionLink("Breyta", "EditCourse", new { id = Model.CourseId }) |
    @Html.ActionLink("Aftur í lista", "CourseIndex")
</p>

</div>
